/*!
 * \file nuObject.h
 * \brief Base class for all objects.
 * \author Nus
 * \date 2008/02/03, 23:41
 */

#ifndef __NUOBJECT_H__
#define __NUOBJECT_H__

#include "nuRTTI.h"
#include "nuAllocator.h"

/*!
 * \class nuObject
 * \brief Base class.
 */
class nuObject
{
  DECLARE_RTTI(nuObject);

public:
  //! \brief Default constructor.
  nuObject() {
    // None...
  }
  
  //! \brief Default destructor.
  virtual ~nuObject() {
    // None...
  }

  //! \brief Override new.
  void* operator new (size_t size,
                      u32 align = 32,
                      const s8* file_loc = NULL,
                      s32 line_loc = 0)
  {
    ASSERT_C(INST(nuAllocator) != NULL);
    return INST(nuAllocator)->getNudeAlloc()->memAlloc(size,
                                                       align,
                                                       file_loc,
                                                       line_loc);
  }
  
  //! \brief Override new.
  void* operator new[] (size_t size,
                        u32 align = 32,
                        const s8* file_loc = NULL,
                        s32 line_loc = 0)
  {
    ASSERT_C(INST(nuAllocator) != NULL);
    return INST(nuAllocator)->getNudeAlloc()->memAlloc(size,
                                                       align,
                                                       file_loc,
                                                       line_loc);
  }

  //! \brief Override delete.
  void operator delete (void* addr) {
    ASSERT_C(INST(nuAllocator) != NULL);
    return INST(nuAllocator)->getNudeAlloc()->memFree(addr);
  }

  //! \brief Override delete.
  void operator delete[] (void* addr) {
    ASSERT_C(INST(nuAllocator) != NULL);
    return INST(nuAllocator)->getNudeAlloc()->memFree(addr);
  }

protected:
  // None...

private:
  // None...

};

#endif
